package Java;

public class circle {
public static final float PI = 3.1415926f;
private float r;
private float area;
private float perimeter;
    public circle(float r) {
        this.r = r;
        calculateArea();
        calculatePerimeter();
    }

    public void setR(float r) { // 修改为接受参数
        this.r = r;
        calculateArea();
        calculatePerimeter();
    }

    public float getR() {
        return r;
    }

    public void calculateArea() {
        area = PI * r * r;
    }

    public void showArea() {
        System.out.println("面积: " + area);
    }

    public void calculatePerimeter() {
        perimeter = 2 * PI * r;
    }

    public void showPerimeter() {
        System.out.println("周长: " + perimeter);
    }

    public static void main(String[] args) {
        circle c = new circle(5.6f);
        c.showArea();
        c.showPerimeter();
    }
}